<template>
  <page-header-wrapper>
    <global-search :list="searchList" @search="handleSearch" @reset="handleReset"> </global-search>
    <a-card :bordered="false">
      <s-table
        ref="table"
        size="default"
        rowKey="ID"
        :columns="columns"
        :data="loadData"
        :pagination="{ showTotal: (total) => `共 ${total} 条` }"
      >
        <span slot="index" slot-scope="text, record, index">{{ index + 1 }} </span>
        <!-- <div slot="action" slot-scope="text, record">
          <y-button type="link" @click="handleDetail(record.ID)">查看</y-button>
        </div> -->
      </s-table>
    </a-card>
  </page-header-wrapper>
</template>

<script>
import { STable, Ellipsis } from '@/components'
import { getChangeHouseList } from '@/api/cityReviewAndManage'

import moment from 'moment'
export default {
  name: 'cityComplexInquireList',
  components: {
    STable,
    Ellipsis,
  },
  data() {
    return {
      queryParam: {
        Mode: 'LIST',
        strContent: {},
      },
      searchList: [
        {
          label: '申请编号',
          fields: 'ApplyNo',
          type: 'input',
          props: {
            placeholder: '请输入申请编号',
          },
        },
        {
          label: '申请人',
          fields: 'Proposer',
          type: 'input',
          props: {
            placeholder: '请输入申请人姓名',
          },
        },
        {
          label: '身份证号',
          fields: 'IDcard',
          type: 'input',
          props: {
            placeholder: '请输入身份证号',
          },
        },
        {
          label: '房屋地址',
          fields: 'EsitesSelect',
          type: 'input',
          props: {
            placeholder: '请输入房屋地址',
          },
        },
        {
          label: '签订时间',
          fields: 'date',
          type: 'range',
          props: {
            valueFormat: 'YYYY-MM-DD',
          },
        },
      ],
      columns: [
        {
          title: '序号',
          align: 'center',
          width: '80px',
          scopedSlots: { customRender: 'index' },
        },
        {
          title: '合同编号',
          align: 'center',
          dataIndex: 'PactNo',
        },
        {
          title: '租户名称',
          align: 'center',
          dataIndex: 'Name',
        },
        {
          title: '原房屋信息',
          align: 'center',
          dataIndex: 'HF_FWIDXX',
          customRender: (text) => <ellipsis length={28}>{text}</ellipsis>,
        },
        {
          title: '新房屋信息',
          align: 'center',
          dataIndex: 'EAddress',
          customRender: (text) => <ellipsis length={28}>{text}</ellipsis>,
        },
        {
          title: '审核状态',
          align: 'center',
          dataIndex: 'HF_SHZT',
          customRender: (text, record) =>
            text === '符合' ? (
              <span class="text-success">{text}</span>
            ) : (
              <a-tooltip>
                <template slot="title">{record.HF_SHMS}</template>
                <span class="text-error">{text}</span>
              </a-tooltip>
            ),
        },
        {
          title: '审核时间',
          align: 'center',
          dataIndex: 'HF_SHSJ',
          customRender: (text) => moment(text).format('YYYY-MM-DD'),
        },
        // {
        //   title: '操作',
        //   align: 'center',
        //   width: '180px',
        //   fixed: 'right',
        //   scopedSlots: { customRender: 'action' }
        // }
      ],
      // 加载数据方法 必须为 Promise 对象
      loadData: (parameter) => {
        const requestParameters = Object.assign({}, parameter, this.queryParam)
        return getChangeHouseList(requestParameters).then((res) => res)
      },
    }
  },
  methods: {
    handleSearch(values) {
      this.queryParam.strContent = values
      this.$refs.table.refresh(true)
    },
    handleReset() {
      this.queryParam.strContent = {}
      this.typeSelect = ''
      this.$refs.table.refresh(true)
    },
    handleButtonSelectChange() {
      this.$refs.table.refresh(true)
    },
    handleDetail(id) {},
  },
}
</script>
<style lang="less" scoped></style>
